#include<bits/stdc++.h>
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
#include"graph.h"
constexpr int inf = numeric_limits < int >::max() >> 1, pw[] = { 1, 3, 9, 27, 81, 243 };
int n, o, d, deg[209], g[209][209], ans[209];
vector < pair < int, int > > son[209], up[209];
inline void dfs(int u)
{
	deg[u] = NumberOfRoads(); int lst = LastRoad();
	For(i, 1, deg[u]) if ( i != lst )
	{
		Move(i, 2); int c = Color();
		if ( c == 2 ) up[u].emplace_back(i, 0), Move(LastRoad(), 2);
		else
		{
			int ret = LastRoad();
			if ( c == 1 ) son[u].emplace_back(i, ++n), g[u][n] = g[n][u] = 1, dfs(n);
			Move(ret, 3);
		}
	}
}
inline void dfs2(int u, int i)
{
	for ( auto &[id, v] : up[u] ) Move(id, u / pw[i] % 3 + 1), v += pw[i] * ( Color() - 1 ),
								  Move(LastRoad(), v / pw[i] % 3 + 1);
	for ( auto [id, v] : son[u] )
	{
		Move(id, u / pw[i] % 3 + 1); int ret = LastRoad();
		dfs2(v, i), Move(ret, v / pw[i] % 3 + 1);
	}
}
void Inspect(int r)
{
	dfs(0); for ( int i = 0 ; pw[i] <= n ; i++ ) dfs2(0, i);
	For(i, 0, n) for ( auto [_, j] : up[i] ) g[i][j] = g[j][i] = 1;
	For(i, 0, n) For(j, 0, n) if ( i != j && !g[i][j] ) g[i][j] = inf;
	For(k, 0, n) For(i, 0, n) if ( i != k ) For(j, 0, n) if ( i != j && j != k )
		g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	For(i, 0, n) For(j, i + 1, n) if ( g[i][j] != inf ) ans[g[i][j]]++;
	For(i, 1, r) Answer(i, ans[i]);
}